﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneHeavenDAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeavenBAL
{
    public class IPRecordBO
    {
        public IPRecordDAL _giftDAL;
        public IPRecordBO()
            : base()
        {
            _giftDAL = new IPRecordDAL();
        }

        public IPRecord GetIPRecord(string ip)
        { 
            string [] content = ip.Split('.');
            if (content != null && content.Length == 4)
            {
                float ips = 0;
                float temp = 0;
                for (int index = content.Length-1; index >= 0; index--)
                {
                    float.TryParse(content[index], out temp);
                    ips = ips + (float)(Math.Pow((double)256, (double)index))* temp;
                }
                return _giftDAL.GetIPRecord(ips);
            }
            return null;
        }
    }
}
